<?php

function load_config()
{
	$arr = array();
	
	$data = read_static_cache('shop_config');
	if($data == false)
	{
		$sql = 'SELECT code,value FROM '. $GLOBALS['ecs']->table('shop_config').' WHERE parent_id>0';
		$res = $GLOBALS['db']->getAll($sql);
		
		foreach($res AS $row)
		{
			$arr[$row['code']] = $row['value'];
		}
		
		if(!isset($GLOBALS['_CFG']['ecs_version']))
		{
			$GLOBALS['_CFG']['ecs_version'] = 'v2.0.5';
		}
		
		$lang_array = array('zh_cn','zh_tw','en_us');
		if(empty($arr['lang']) || !in_array($arr['lang'], $lang_array))
		{
			$arr['lang'] = 'zh_cn';
		}
		
		write_static_cache('shop_config',$arr);
	}
	else 
	{
		$arr = $data;
	}
	
	return $arr;
}

